package com.gxa.p2p.util;

import com.gxa.p2p.businessExceptionCode.ErrorCode;
import com.gxa.p2p.exception.BusinessException;
import com.gxa.p2p.service.Userservice;
import com.gxa.p2p.service.VerifyCodeService;
import com.gxa.p2p.service.impl.VerifyCodeServiceImpl;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
//封装的发送短信方法
public class SendMessageUtil {

Integer code=null;
public Integer getcode(){
    return code;
}

//        @Resource(name = "VerifyCodeServiceImpl")
//        VerifyCodeServiceImpl verifyCodeService;
    VerifyCodeServiceImpl verifyCodeService=new VerifyCodeServiceImpl();

        public MapUtil sendVerifyCode(String phonemap) {
            //System.out.println(phonemap);
//           String phoneNumber = (String) phonemap.get("phoneNumber");
            System.out.println("接收到前端请求");
            MapUtil json = new MapUtil();
            try {
                verifyCodeService.sendVerifyCode(phonemap);
                code = verifyCodeService.getCode();

                json.setCode(0);
                json.setMsg("验证码发送成功");

            } catch (Exception e) {
                json.setCode(1);
                json.setMsg(e.getMessage());
            }

            return json;

        }



    }

